#install.packages("ggplot2")
library(ggplot2)

df = read.csv('data/uk_polar.csv')
df$smooth = smooth.spline(df$euclidean_distance,spar = 0.45)$y
pdf("figures/figureA3a.pdf",width=7,height=5,paper='special')
ggplot(df, aes(year,euclidean_distance)) + theme_bw() +
  geom_line(col='darkblue', lwd=0.5, lty=2) + 
  geom_line(aes(year,smooth),col='darkblue', lty=1, lwd=2) + 
  scale_x_continuous(breaks=c(1940,1950,1960,1970,1980,1990,2000,2010)) +
  xlab("Year") + 
  ylab("Euclidean Distance")
dev.off()  

df = read.csv('data/us_polar.csv')
df = df[df$year>=1935,]
df$smooth = smooth.spline(df$euclidean_distance,spar = 0.45)$y
pdf("figures/figureA3b.pdf",width=7,height=5,paper='special')
ggplot(df, aes(year,euclidean_distance)) + theme_bw() +
  geom_line(col='darkblue', lwd=0.5, lty=2) + 
  geom_line(aes(year,smooth),col='darkblue', lty=1, lwd=2) + 
  scale_x_continuous(breaks=seq(1935,2015,6)) +
  xlab("Year") + 
  ylab("Euclidean Distance")
dev.off()  

df = read.csv('data/can_polar.csv')
df = df[df$year>=1935,]
df$smooth = smooth.spline(df$euclidean_distance,spar = 0.45)$y
pdf("figures/figureA3c.pdf",width=7,height=5,paper='special')
ggplot(df, aes(year,euclidean_distance)) + theme_bw() +
  geom_line(col='darkblue', lwd=0.5, lty=2) + 
  geom_line(aes(year,smooth),col='darkblue', lty=1, lwd=2) + 
  scale_x_continuous(breaks=c(1940,1950,1960,1970,1980,1990,2000,2010)) +
  xlab("Year") + 
  ylab("Euclidean Distance")
dev.off()
